# -*- coding: utf-8 -*-
# @Time    : 2020/11/14 12:51
# @Author  : DuJiabao
# @File    : single_neural_network.py
# @Description :

import tensorflow as tf
import tensorflow.keras as keras
import numpy as np

if __name__ == '__main__':
    model = keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
    model.compile(optimizer="sgd", loss="mean_squared_error")
    xs = np.array([-1., 0., 1., 2., 3., 4., 20], dtype=float)
    ys = np.array([-3., -1., 1., 3., 5., 7., 39], dtype=float)
    model.fit(xs, ys, epochs=1000)
    print(model.predict([10.0]))
